﻿using edem2simpack.Models;
using edem2simpack.Views;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Forms;
using System.Windows.Shell;
using System.Xml;

namespace edem2simpack.ViewModels
{

    public class CosimulationViewModel : NotifyObject
    {    

        private string _fmuFile;
        public string FmuFile
        {
            get => _fmuFile;
            set
            {
                if (_fmuFile != value)
                {
                    _fmuFile = value;                    
                }
                RaisePropertyChanged(nameof(FmuFile));
            }
        }

        private string _spckFile;
        public string SpckFile
        {
            get => _spckFile;
            set
            {
                if (_spckFile != value)
                {
                    _spckFile = value;                    
                }
                RaisePropertyChanged(nameof(SpckFile));
            }
        }

        private CommandObject<RoutedEventArgs> _load_FmuFile;
        public CommandObject<RoutedEventArgs> Load_FmuFile
        {
            get
            {
                if (_load_FmuFile == null)
                    _load_FmuFile = new CommandObject<RoutedEventArgs>(
                        new Action<RoutedEventArgs>(e =>
                        {
                            var openFileDialog = new Microsoft.Win32.OpenFileDialog()
                            {
                                Filter = "FMU documents (.fmu)|*.fmu|All files (*.*)|*.*"
                            };
                            var result = openFileDialog.ShowDialog();
                            if (result == true)
                            {
                                FmuFile = openFileDialog.FileName;
                            }
                            else
                            {
                                FmuFile = null;
                            }
                            
                        }));

                return _load_FmuFile;
            }
        }

        private CommandObject<RoutedEventArgs> _load_SpckFile;
        public CommandObject<RoutedEventArgs> Load_SpckFile
        {
            get
            {
                if (_load_SpckFile == null)
                    _load_SpckFile = new CommandObject<RoutedEventArgs>(
                        new Action<RoutedEventArgs>(e =>
                        {
                            var openFileDialog = new Microsoft.Win32.OpenFileDialog()
                            {
                                Filter = "SIMPACK documents (.spck)|*.spck|All files (*.*)|*.*"
                            };
                            var result = openFileDialog.ShowDialog();
                            if (result == true)
                            {
                                SpckFile = openFileDialog.FileName;
                            }
                            else
                            {
                                SpckFile = null;
                            }


                        }));
                return _load_SpckFile;
            }
        }

        
    }
}
